//
//  AboutViewController.m
//  one·一个  tyw
//
//  Created by tyw on 15/9/12.
//  Copyright (c) 2015年 tyw. All rights reserved.
//

#import "AboutViewController.h"
#import "DayNightLabel.h"

@interface AboutViewController ()

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor clearColor];
    [self _createNavBar];
    [self _createSubViews];
}

- (void)_createNavBar {
    self.navigationItem.titleView = nil;
    self.navigationItem.title = @"关于";
}

- (void)_createSubViews {
    UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    scrollView.contentSize = CGSizeMake(kWidth, 1000);
    scrollView.scrollEnabled = YES;
    scrollView.showsVerticalScrollIndicator = NO;
    scrollView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:scrollView];
    
    //位于上半部的白色部分
    UIView* view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 400)];
    view1.backgroundColor = [UIColor whiteColor];
    view1.alpha = 0.3;
    [scrollView addSubview:view1];
    
    UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(kWidth/2-40, 60, 80, 80)];
    imageView.image = [UIImage imageNamed:@"Icon-120"];
    imageView.layer.cornerRadius = 8;
    imageView.layer.masksToBounds = YES;    //超出就修剪
    [scrollView addSubview:imageView];
    
#warning 富文本实现行间距设置
    NSString* str1 = @"[ONE·一个]是由韩寒主编和监制,原《独唱团》主创成员共同制作的文艺应用软件。发布不到24小时就登上AppStore免费排行总榜第一名。";
    NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str1];
    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle1 setLineSpacing:5];
    [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [str1 length])];
    DayNightLabel* label1 = [[DayNightLabel alloc] initWithFrame:CGRectMake(20, 200, kWidth-40, 0)];
    label1.textAlignment = NSTextAlignmentLeft;
    label1.numberOfLines = 0;
    [label1 loadLabelColor];
    label1.font = [UIFont systemFontOfSize:14];
    [scrollView addSubview:label1];
    [label1 setAttributedText:attributedString1];
    [label1 sizeToFit];
    
    NSString* str2 = @"不追热点，不关时政，不要喧哗，不惹纷争。关掉微博，离开微信，带着微笑，[一个]足够简单。";
    NSMutableAttributedString * attributedString2 = [[NSMutableAttributedString alloc] initWithString:str2];
    [attributedString2 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [str2 length])];
    DayNightLabel* label2 = [[DayNightLabel alloc] initWithFrame:CGRectMake(20, 300, kWidth-40, 0)];
    label2.textAlignment = NSTextAlignmentLeft;
    label2.numberOfLines = 0;
    [label2 loadLabelColor];
    label2.font = [UIFont systemFontOfSize:14];
    [scrollView addSubview:label2];
    [label2 setAttributedText:attributedString2];
    [label2 sizeToFit];
    
    
    
    //位于下半部的暗色部分
    UIView* view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 400, kWidth, 900)];
    view2.backgroundColor = [UIColor colorWithRed:220.0/255 green:220.0/255 blue:220.0/255 alpha:1];
    view2.alpha = 0.3;
    [scrollView addSubview:view2];
    
    //联系我们
    DayNightLabel* label3 = [[DayNightLabel alloc] initWithFrame:CGRectMake(0, 450, kWidth, 100)];
    label3.text = @"联系我们";
    label3.textAlignment = NSTextAlignmentCenter;
    [label3 loadLabelColor];
    label3.font = [UIFont systemFontOfSize:20];
    [scrollView addSubview:label3];
    
    //@一个工作室
    UILabel* label4 = [[UILabel alloc] initWithFrame:CGRectMake(kWidth/2-150-20, 550, 150, 100)];
    label4.text = @"@一个工作室";
    label4.textAlignment = NSTextAlignmentRight;
    label4.textColor = [UIColor colorWithRed:53.0/255 green:147.0/255 blue:218.0/255 alpha:1];
    [scrollView addSubview:label4];
    //@亭林镇工作室
    UILabel* label5 = [[UILabel alloc] initWithFrame:CGRectMake(kWidth/2+20, 550, 150, 100)];
    label5.text = @"@亭林镇工作室";
    label5.textAlignment = NSTextAlignmentLeft;
    label5.textColor = [UIColor colorWithRed:53.0/255 green:147.0/255 blue:218.0/255 alpha:1];
    [scrollView addSubview:label5];
    
    //图片投稿、文章投稿、问题投稿、商务合作、用户反馈
    NSArray* labelName = @[@"图片投稿",@"文章投稿",@"问题投稿",@"商务合作",@"用户反馈"];
    NSArray* urlName = @[@"onetupian@wufazhuce.com",
                            @"onewenzhang@wufazhuce.com",
                            @"onewenti@wufazhuce.com",
                            @"onetbd@wufazhuce.com",
                            @"oneteam@wufazhuce.com"];
    for (int i = 0; i < 5; i++) {
        DayNightLabel* label1 = [[DayNightLabel alloc] initWithFrame:CGRectMake(40, 650+50*i, kWidth-80, 20)];
        label1.text = labelName[i];
        label1.textAlignment = NSTextAlignmentLeft;
        [label1 loadLabelColor];
        label1.font = [UIFont systemFontOfSize:14];
#warning 在这里用View1添加子视图，会发现它的字体颜色与“联系我们”略有不同，效果不错
        [view1 addSubview:label1];
        
        UILabel* label2 = [[UILabel alloc] initWithFrame:CGRectMake(40, 670+50*i, kWidth-80, 20)];
        label2.text = urlName[i];
        label2.textAlignment = NSTextAlignmentLeft;
        label2.textColor = [UIColor colorWithRed:53.0/255 green:147.0/255 blue:218.0/255 alpha:1];
        [scrollView addSubview:label2];
    }
    
    
    //底部文字
    DayNightLabel* label6 = [[DayNightLabel alloc] initWithFrame:CGRectMake(0, 950, kWidth, 20)];
    label6.text = @"2012-2015 [ONE·一个]";
    label6.textAlignment = NSTextAlignmentCenter;
    [label6 loadLabelColor];
    label6.font = [UIFont systemFontOfSize:15];
    [view1 addSubview:label6];
    
    DayNightLabel* label7 = [[DayNightLabel alloc] initWithFrame:CGRectMake(0, 970, kWidth, 20)];
    label7.text = @"沪ICP备13042400号";
    label7.textAlignment = NSTextAlignmentCenter;
    [label7 loadLabelColor];
    label7.font = [UIFont systemFontOfSize:15];
    [view1 addSubview:label7];
}

@end
